package com.cloudkinto.enumType.order.inbound;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.cloudkinto.vo.common.CommonKvVo;

import java.util.ArrayList;

/**
 * @author long
 */

public enum ArrivalModeEnum implements IEnum<Integer> {
    /**
     *
     */
    one(1, "快递包裹", "快递包裹", "Express parcel", "Parcel/快递包裹"),
    two(2, "箱", "箱", "Box", "Carton/箱"),
    three(3, "托盘/卡板", "托盘/卡板", "Tray/Pallet", "Pallet/托盘卡板"),
    four(4, "货柜（20GP）", "20GP", "Container(20GP)", "Container/货柜(20GP)"),
    five(5, "货柜（20HQ）", "20HQ", "Container(20HQ)", "Container/货柜(20HQ)"),
    six(6, "货柜（40GP）", "40GP", "Container(40GP)", "Container/货柜(40GP)"),
    seven(7, "货柜（40HQ）", "40HQ", "Container(40HQ)", "Container/货柜(40HQ)"),
    eight(8, "货柜（45HQ）", "45HQ", "Container(45HQ)", "Container/货柜(45HQ)"),
    nine(9, "货柜（53HQ）", "53HQ", "Container(53HQ)", "Container/货柜(53HQ)"),
    ten(10, "其他", "其他", "Other", "Other/其他"),
    eleven(11, "平台自提", "平台自提", "Platform pick-up", "Platform pick-up/平台自提"),
    twelve(12, "三方头程", "三方头程", "Third-party headway", "Tripartite Head/三方头程"),
    thirteen(13, "自发头程", "自发头程", "Self-sent headway", "Spontaneous Head/自发头程");

    private final Integer code;

    private final String name;

    private final String simpleName;

    private final String enName;

    private final String details;

    ArrivalModeEnum(Integer code, String name, String simpleName, String enName, String details) {
        this.code = code;
        this.name = name;
        this.simpleName = simpleName;
        this.enName = enName;
        this.details = details;
    }

    @Override
    public Integer getValue() {
        return code;
    }

    public static ArrayList<CommonKvVo> getArrivalModeList() {
        ArrayList<CommonKvVo> list = new ArrayList<>();
        for (ArrivalModeEnum arrivalModeEnum : values()) {
            list.add(
                    CommonKvVo.builder()
                            .label(arrivalModeEnum.name)
                            .value(arrivalModeEnum.getValue())
                            .build()
            );
        }
        return list;
    }


    public static ArrayList<CommonKvVo> getArrivalModeListSim() {
        ArrayList<CommonKvVo> list = new ArrayList<>();
        for (ArrivalModeEnum arrivalModeEnum : values()) {
            list.add(
                    CommonKvVo.builder()
                            .label(arrivalModeEnum.simpleName)
                            .value(arrivalModeEnum.getValue())
                            .build()
            );
        }
        return list;
    }

    public static String getEnName(Integer value) {
        for (ArrivalModeEnum arrivalModeEnum : values()) {
            if (arrivalModeEnum.getValue().equals(value)) {
                return arrivalModeEnum.enName;
            }
        }
        return null;
    }

    public static Integer getCode(String details) {
        for (ArrivalModeEnum arrivalModeEnum : values()) {
            if (arrivalModeEnum.details.equals(details)) {
                return arrivalModeEnum.code;
            }
        }
        return null;
    }
}
